import axios from 'axios'
import store from '@/store/index'
import dayjs from 'dayjs'
import {
	Toast
} from 'vant';
// 创建axios实例

const service = axios.create({
	baseURL: myConfig.defaultURL,
	timeout: 30000,
	method: 'post',
})
// request拦截器
service.interceptors.request.use(config => {
	//拦截配置地址
	config.baseURL=store.getters.isWenzhouUrl
	return config
}, error => {
	console.log(error)
	Promise.reject(error)
})

// 响应拦截器
service.interceptors.response.use(res => {
		let result = res.data;
		if (result.success) {

		} else {
			setTimeout(() => {
				Toast({
					message: result.msg+'入参：'+JSON.stringify(res.config.params) || '业务出错',
				});

			})
		}
		return result;

	},
	error => {
		Toast({
			message: error.message || '服务出错',

		});
		return error
	}
)
export default service